import 'package:flutter/material.dart';
import 'package:hixing_app/const/color_res.dart';

class SettingMenuItem extends StatefulWidget {
  const SettingMenuItem(
      {super.key,
      this.onTap,
      this.height,
      this.btmBorder = true,
      this.topBorder = false,
      this.marginHorizontal = 16,
      this.label = "菜单",
      this.suffixIconLeftPadding = 16,
      this.leadingWidget,
      this.rightContentWidget = const SizedBox.shrink(),
      this.suffixWidget});

  final VoidCallback? onTap;
  final bool btmBorder;
  final bool topBorder;
  final String label;
  final double? height;
  final double suffixIconLeftPadding;
  final Widget? suffixWidget;
  final double marginHorizontal;
  final Widget rightContentWidget;
  final Widget? leadingWidget;

  @override
  _SettingMenuItemState createState() => _SettingMenuItemState();
}

class _SettingMenuItemState extends State<SettingMenuItem> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: widget.onTap,
      child: Container(
        color: Colors.white,
        child: Container(
          height: widget.height ?? 52,
          decoration: BoxDecoration(
              border: Border(
            bottom: widget.btmBorder
                ? BorderSide(color: ColorRes.borderF6, width: 1)
                : BorderSide.none,
            top: widget.topBorder
                ? BorderSide(color: ColorRes.borderF6, width: 1)
                : BorderSide.none,
          )),
          margin: EdgeInsets.symmetric(horizontal: widget.marginHorizontal),
          child: Row(
            children: [
              widget.leadingWidget ??
                  Text(
                    widget.label,
                    style: const TextStyle(
                        fontSize: 16, fontWeight: FontWeight.bold),
                  ),
              const Spacer(),
              widget.rightContentWidget,
              widget.suffixWidget ??
                  Padding(
                    padding:
                        EdgeInsets.only(left: widget.suffixIconLeftPadding),
                    child: const Icon(Icons.arrow_right,
                        // AppIconR.shouyeGengduo,
                        color: ColorRes.greyText70,
                        size: 20),
                  ),
            ],
          ),
        ),
      ),
    );
  }
}
